<template>
  <div>
    <FormPanel ref="formPanel" :list="formList" :formType="type" @formChange="formChangeHandle" :isSubmitBtn="false" :collapse="false" labelWidth="110" />

    <div
      :style="{
        position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'center'
      }"
    >
      <el-button @click="closeDrawer">关 闭</el-button>
    </div>
  </div>
</template>
<script>
import moment from 'moment';
import { dictionary } from '@/utils/dictMixin';
import { queryById } from '@/api/omFinance/RebateManage/RebateStatementQuery';

export default {
  mixins: [dictionary],
  props: ['type', 'rowData'],

  data() {
    this.saveData = null;
    return {
      formList: this.createdFrom(),
      list: []
    };
  },
  created() {
    this.init();
  },
  methods: {
    async init() {
      const res = await queryById(this.rowData.id);
      if (res.resultCode == 200) {
        this.formList.map(x => {
          x.initialValue = res.data[x.fieldName];
        });
      }
    },
    formChangeHandle(val) {
      this.saveData = val;
    },
    closeDrawer() {
      this.$emit('close');
    },

    createdFrom() {
      return [
        // {
        //   type: 'BREAK_SPACE',
        //   label: '客户信息'
        // },
        {
          type: 'INPUT',
          label: '对账单号',
          fieldName: 'verifyNo',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '账单名称',
          fieldName: 'verifyName',
          placeholder: ''
        },

        {
          type: 'SELECT',
          label: '对账分类',
          fieldName: 'verifyType',
          placeholder: '请选择',
          itemList: this.createDictList('6086')
        },
        {
          type: 'INPUT',
          label: '经销商代码',
          fieldName: 'dealerCode',
          placeholder: ''
        },
        {
          type: 'INPUT',
          label: '经销商名称',
          fieldName: 'dealerName',
          placeholder: ''
        },
        {
          type: 'DATE',
          label: '生成日期',
          fieldName: 'createdAt',
          placeholder: ''
        },
        {
          type: 'INPUT',
          label: '整车款余额',
          fieldName: 'vehicleAccountAmount',
          placeholder: ''
        },
        {
          type: 'INPUT',
          label: '整车返利余额',
          fieldName: 'vehicleRebateAmount',
          placeholder: ''
        },
        {
          type: 'INPUT',
          label: '备件款余额',
          fieldName: 'partAccountAmount',
          placeholder: ''
        },
        {
          type: 'INPUT',
          label: '备件返利余额',
          fieldName: 'partRebateAmount',
          placeholder: ''
        },
        {
          type: 'INPUT',
          label: '建店保证金余额',
          fieldName: 'depositAmount',
          placeholder: ''
        },
        {
          type: 'INPUT',
          label: '其他类应收款项',
          fieldName: 'otherInAmount',
          placeholder: ''
        },
        {
          type: 'INPUT',
          label: '其他类应付款项',
          fieldName: 'otherOutAmount',
          placeholder: ''
        },
        {
          type: 'INPUT',
          label: '账户资金所属公司',
          fieldName: 'orgCompanyName',
          placeholder: ''
        }
      ];
    }
  }
};
</script>
